import { onShareAppMessage } from '@dcloudio/uni-app'
interface shareType {
  title?: string
  path?: string
  imageUrl?: string
}
/**
 *
 * @returns
 */
const useShare = () => {
  const shareData: shareType = {
    title: '', // 默认为小程序名称
    path: '/pages/index', // 默认为当前页面路径
    imageUrl: 'https://share.jpg', // 默认为当前页面的截图
  }
  //分享好友
  const aonShareAppMessage = (share?: shareType) => {
    return onShareAppMessage(({ webViewUrl }) => {
      return share || shareData
    })
  }
  return { aonShareAppMessage }
}
export default useShare

// eg:
// import useShare from '@/hooks/useShare'
// const { aonShareAppMessage } = useShare()
// aonShareAppMessage()
